Visualisation This blog is an analysis which describes how major world events and other economic factors detrimentally impacts the country’s prosperity index as well as how the government manages their country’s economy and governs how their residents live based on the prosperity index. Below is an interactive table showing the pillars of the countries.
library(DT)
library(readxl)
Data <- read_excel("Legatum_index.xlsx",
sheet = "Pillars")
Data <- Data[,-15:-24]
Data %>%
datatable(rownames = FALSE,
filter = list(position = "top"))
By playing around the interactive table, we can see that the country with highest as well as lowest ranking in PI, economics, business, government, education, heal, safety and environment.
library(readxl)
Data2 <- read_excel("Legatum_index.xlsx",
sheet = "Prosperity")
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.3.6 ✔ purrr 0.3.4
## ✔ tibble 3.1.7 ✔ dplyr 1.0.9
## ✔ tidyr 1.2.1 ✔ stringr 1.4.1
## ✔ readr 2.1.2 ✔ forcats 0.5.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
library(plotly)
##
## Attaching package: 'plotly'
##
## The following object is masked from 'package:ggplot2':
##
## last_plot
##
## The following object is masked from 'package:stats':
##
## filter
##
## The following object is masked from 'package:graphics':
##
## layout
Data2 <- Data2 %>%
mutate(PI=ifelse(rank_PI2016>10,">10",country))%>%
select(c('PI','rank_PI2016','PI2016'))
ggplotly(ggplot(data=Data2)+geom_col(aes(x=PI,y=rank_PI2016))+ylim(0,11)+
ggtitle("Top 10 countries with best PI in rank order in 2016")+
theme(plot.title=element_text(hjust=0.1,face="bold"))+
labs(x="Name of countries",y="Rank"))
## Warning: Removed 138 rows containing missing values (position_stack).
From the bar graph, we can see that the country with the highest rank for prosperity index is New Zealand followed by Norway, Finland, Switzerland, Canada, Australia, Netherlands,Sweden, Denmark then United Kingdom.